package com.edmond.service.impl;

import com.edmond.entity.Category;
import com.edmond.mapper.CategoryMapper;
import com.edmond.service.ICategoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CategoryService implements ICategoryService {
    //  自动注入 mapper对象完成数据访问操作
    @Resource
    private CategoryMapper categoryMapper;

    @Override
    public List<Category> list() {
        return categoryMapper.findAll();
    }

    /**
     * 添加商品分类业务实现
     *
     * @param category
     * @return
     */
    @Override
    public Integer insert(Category category) {
        return categoryMapper.doAdd(category);
    }

    //  根据 id 查询商品类别信息
    @Override
    public Category find(Integer categoryId) {
        return categoryMapper.find(categoryId);
    }

    //  根据 id 修改商品名称
    @Override
    public Integer update(Category category) {
        return categoryMapper.doUpdate(category);
    }
}
